
<?php

defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$uniacid = $_SESSION['uniacid'];
$mid = $_SESSION['uid'];
$return['setting']=$this->plugin_setting('basic');
$return['advs']=$basic['image'];
if($_RQ['op']=='main'){
	/*******main*******/
	//所有活动
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$return['params']=$params=array();
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'endtime >'=>time());
	if(!empty($_RQ['keyword'])){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	if($_RQ['cid']){
		$params['categoryid']=intval($_RQ['cid']);
	}
	$fields=array('id','categoryid','uniacid','title','desc','image','status','goodsid','sales','endtime','starttime','ishot','displayorder','createtime');
	$acts=pdo_getslice('jy_sendgoods_act',$params,array($pindex,$psize),$total,$fields,'','displayorder desc');
	$acts_count=count($acts);
	if($acts){
		foreach($acts as &$item){
			$goods=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['goodsid']));
			$item['image']=tomedia($goods['image']);
			$item['goods']=$goods;
			$item['endstatus']=$item['starttime']<time() ? $item['endtime']>time()? 1 : 2 : 0;
			$item['statustitle']=$item['starttime']<time() ? $item['endtime']>time()? '去购买' : '已结束' : '未开始';
		}
	}
	$return['list']=$acts;
	$return['acts_count']=$acts_count;
	exi($return);
}